from rest_framework.generics import ListCreateAPIView, RetrieveUpdateDestroyAPIView

from book.modelserializer import BookModelSerialzier
from book.models import BookInfo


class BooksView(ListCreateAPIView):
    # GenericAPIView和APIView使用区别 指定两个属性
    # 序列化器属性
    serializer_class = BookModelSerialzier
    # 查询集属性
    queryset = BookInfo.objects.all()

    # 指定视图限流名
    throttle_scope = 'BooksView'


class BookView(RetrieveUpdateDestroyAPIView):
    # 指定序列化器属性
    serializer_class = BookModelSerialzier
    # 指定查询集属性
    queryset = BookInfo.objects.all()

    # 指定视图限流名
    throttle_scope = 'BookView'
